import Vue from "vue";
import Router from "vue-router";
import home from "../components/index.vue";
import index from "../components/coupon/index.vue";
import searchTable from "../components/public/searchTable.vue";

import activity from "../components/coupon/activity.vue";
import aio from "../components/coupon/aio.vue";
import grant from "../components/coupon/grant.vue";

import creatCoupon from "../components/children/creatCoupon.vue";

// const originalPush = Router.prototype.push
// Router.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }

Vue.use(Router);
export default new Router({
  routes: [
    {
      //主页
      path: "/",
      name: "home",
      component: home,
      //重定向
      redirect: "/index",
      children: [
        {
          //设置优惠券
          path: "/activity",
          name: "activity",
          component: activity,
        },
        {
          //一体机优惠券管理
          path: "/aio",
          name: "aio",
          component: aio,
        },
        {
          // 效果统计
          path: "/index",
          name: "index",
          component: index,
        },

        {
          //发放优惠券
          path: "/grant",
          name: "grant",
          component: grant,
        },
      ],
    },
    {
      //发放优惠券
      path: "/creatCoupon",
      name: "creatCoupon",
      component: creatCoupon,
    },
    {
      //一体机抽奖
      path: "/onemachinelottery",
      component: () => import("../components/OneMachineLottery"),
      redirect: "/onemachinelottery/winrecord",
      children: [
        {
          path: "lotteryset",
          component: () => import("../components/OneMachineLottery/LotterySet"),
        },
        {
          path: "winrecord",
          component: () => import("../components/OneMachineLottery/WinRecord"),
        },
      ],
    },
  ],
  mode: "history",
});
